package org.grow.bill.controller;

import org.grow.bill.domain.LeaveBill;
import org.grow.bill.mapper.LeaveBillMapper;
import org.grow.bill.service.CodeServiceF;
import org.grow.bill.service.LeaveBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

/**
 * @Author: xwg
 * @CreateDate: 2025/10/13
 */

@RequestMapping("/leaveBill")
@RestController
public class LeaveBillController {

    @Autowired
    private LeaveBillMapper leaveBillMapper;
    @Autowired
    private LeaveBillService leaveBillService;

    @Autowired
    private CodeServiceF codeServiceF;
    @PostMapping("/insert")
    public LeaveBill insert(@RequestBody LeaveBill leaveBill) {
//        进行feign远程调用 openFeign
//        http://localhost:8082/code/next?prefix=YT
        leaveBill.setBillId(codeServiceF.next("YT"));
        leaveBill.setUpdateTime(LocalDateTime.now());
        leaveBill.setApplier("zhangsan");
        leaveBillService.save(leaveBill);
        return leaveBill;

    }
}
